var DOMReady = {

onDOMReadyHandler : function() {},

// returns true if listener is active, otherwise - false (that means that
// window.onload is used
listenDOMReady : function() {

var browser = navigator.userAgent;
var is_safari = /(safari|webkit)/i.test(browser);
var is_opera = /opera/i.test(browser);
var is_msie = /msie/i.test(browser);
var is_mozilla = /mozilla/i.test(browser) && !/(compatible|webkit)/i.test(browser);

	if (is_opera || is_mozilla){
		this.attachEvent(document, "DOMContentLoaded", this.onDOMReadyHandler);
		return true;
	}

	if (is_msie) {
		document.write('<script id="dr_ie_script" defer="true" src="https://javascript:false;"><\/script>');
		document.getElementById("dr_ie_script").onreadystatechange = function(){
			if (this.readyState == "complete") DOMReady.onDOMReadyHandler();
		};
		return true;
	}

	if (is_safari) {
		this.domReadyTimer = window.setInterval(function(){
			if (document.readyState == "loaded" ||
				document.readyState == "complete") {

				window.clearInterval(DOMReady.domReadyTimer);
				DOMReady.onDOMReadyHandler();

			}
		}, 10);

		return true;
	}


	// use onload event otherwise
	this.attachEvent(window, "load", DOMReady.onDOMReadyHandler);

	return false;
},

// timer (used with Safari)
domReadyTimer : null,

// set event handler
attachEvent : function(obj, event, handler) {

	if (obj.addEventListener) {
		obj.addEventListener(event, handler, false);
	} else {
		if (obj.attachEvent) {
			obj.attachEvent('on'+event, handler);
		}
	}
},


// remove event handler
detachEvent : function(obj, event, handler) {

	if (obj.removeEventListener) {
		obj.removeEventListener(event, handler, false);
	} else {
		if (obj.detachEvent) {
			obj.detachEvent('on'+event, handler);
		}
	}
}

};